Skip to content

Give the structlog→Sentry payload a deep module#129

Merged
lesnik512 merged 5 commits into
mainfrom
feat/structured-log-payload
Jun 24, 2026
Merged

Give the structlog→Sentry payload a deep module#129
lesnik512 merged 5 commits into
mainfrom
feat/structured-log-payload

Conversation

@lesnik512

Copy link
Copy Markdown
Member

What

Gives the structlog→Sentry log-line contract a single owner: a new StructuredLogPayload value object in logging_factory.py. Its parse classmethod reconstructs a rendered structlog line into message / extra / skip_sentry, owning the meta-key vocabulary (STRUCTLOG_META_KEYS) and the meta-stripping internally. The Sentry instrument shrinks to orchestration — it keeps only the Sentry-event-shape guards and maps the parsed payload onto the event.

Why

The contract was split between a serializer in logging_factory and a parser in sentry_instrument, joined only by a formatted.startswith("{") sniff, with the meta-key set hand-maintained far from the chain that emits those keys. Rename a key or add a meta-processor and Sentry enrichment silently degraded, with no test crossing the producer's serializer and the consumer's parser together. (Surfaced as candidate 1 of the 2026-06-23 architecture review.)

Changes

  • logging_factory.py — new StructuredLogPayload + STRUCTLOG_META_KEYS; a cross-reference comment at tracer_injection in logging_instrument.py.
  • sentry_instrument.pyenrich_sentry_event_from_structlog_log now delegates to parse; IGNORED_STRUCTLOG_ATTRIBUTES retained as a silent back-compat alias of STRUCTLOG_META_KEYS.
  • Tests — new test_structured_log_payload.py (parse table + round-trip drift net, incl. the relocated DES-4 regression); Sentry tests slimmed to the three orchestration outcomes plus a skip-before-message ordering pin.
  • Docsarchitecture/instruments.md and CLAUDE.md name the seam; change bundle under planning/changes/2026-06-23.01-structured-log-payload/.

Verification

196 passed, 100% coverage; just lint clean (ruff + ty). Behavior preserved — the three Sentry outcomes and skip-before-message ordering are pinned.

🤖 Generated with Claude Code

lesnik512 and others added 5 commits June 23, 2026 22:34
Introduces StructuredLogPayload + STRUCTLOG_META_KEYS in logging_factory,
owning the structlog log-line parse and meta-key vocabulary. Adds a
round-trip drift net and a cross-reference comment at the producer chain.
Sentry rewiring follows in a later task.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
enrich_sentry_event_from_structlog_log now owns only the Sentry-event-shape
guards and delegates line-content interpretation to StructuredLogPayload.parse.
IGNORED_STRUCTLOG_ATTRIBUTES is kept as a back-compat alias of STRUCTLOG_META_KEYS.
Sentry tests slim to the three orchestration outcomes plus the skip-before-message
ordering pin; the DES-4 regression moved to the value-object layer.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Promote the Logging↔Sentry integration write-up to name the StructuredLogPayload
seam and STRUCTLOG_META_KEYS vocabulary, and add the change bundle (design + plan).
Bundle status is approved; pr/outcome fill at merge time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lesnik512 lesnik512 merged commit 16816d5 into main Jun 24, 2026
7 checks passed
@lesnik512 lesnik512 deleted the feat/structured-log-payload branch June 24, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant